package com.flying.scorer.config;

import com.flying.refdata.service.MarketDataService;
import com.flying.refdata.service.ReportService;
import com.flying.scorer.model.CalcType;
import com.flying.scorer.model.ScorerInfo;
import com.flying.scorer.score.equity.CompoundEquityScorer;
import com.flying.scorer.score.equity.EquityScorer;
import com.flying.scorer.score.equity.marketdata.*;
import com.flying.scorer.score.equity.multi.ROEPBEquityScorer;
import com.flying.scorer.score.equity.quarterlyreport.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ScorerConfig {
    @Bean
    public MarketDataService marketDataService() {
        return new MarketDataService();
    }

    @Bean
    public ReportService reportService() {
        return new ReportService();
    }

    @Bean
    public EquityScorer noPbScorer() {
        ScorerInfo scorerInfo = new ScorerInfo();
        scorerInfo.setName("NoPB");
        scorerInfo.setCalcType(CalcType.ACCUMULATION);

        CompoundEquityScorer noPB = new CompoundEquityScorer(scorerInfo);
        // technical analysis related scorer.
        noPB.add(new MA5EquityScorer(marketDataService()));
        noPB.add(new MA10EquityScorer(marketDataService()));
        noPB.add(new MA30EquityScorer(marketDataService()));
        noPB.add(new MA120EquityScorer(marketDataService()));
        noPB.add(new MA250EquityScorer(marketDataService()));
        // Static financial data related scorer.
        noPB.add(new CashFlowGrowthRateEquityScorer(reportService()));
        noPB.add(new ParentNetProfitGrowthRateEquityScorer(reportService()));
        noPB.add(new RevenueGrowthRateEquityScorer(reportService()));
        noPB.add(new ROE15EquityScorer(reportService()));
        // trend variation related scorer.
        noPB.add(new ParentNetProfitGrowthRateVariationEquityScorer(reportService()));
        noPB.add(new RevenueGrowthRateVariationEquityScorer(reportService()));
        return noPB;
    }

    @Bean
    public EquityScorer withPbScorer() {
        ScorerInfo scorerInfo = new ScorerInfo();
        scorerInfo.setName("WithPB");
        scorerInfo.setCalcType(CalcType.ACCUMULATION);

        CompoundEquityScorer withPB = new CompoundEquityScorer(scorerInfo);
        // technical analysis related scorer.
        withPB.add(new MA5EquityScorer(marketDataService()));
        withPB.add(new MA10EquityScorer(marketDataService()));
        withPB.add(new MA30EquityScorer(marketDataService()));
        withPB.add(new MA120EquityScorer(marketDataService()));
        withPB.add(new MA250EquityScorer(marketDataService()));
        // Static financial data related scorer.
        withPB.add(new ParentNetProfitGrowthRateEquityScorer(reportService()));
        withPB.add(new RevenueGrowthRateEquityScorer(reportService()));
        withPB.add(new ROE20EquityScorer(reportService()));
        withPB.add(new ROEPBEquityScorer(marketDataService(), reportService()));
        // trend variation related scorer.
        withPB.add(new RevenueGrowthRateVariationEquityScorer(reportService()));
        return withPB;
    }
}